# -*- coding:utf-8 -*-

__author__ = 'stevezhou'

import urllib
import gzwechat_sdk

# PLATFORM = 'PROD'
# PLATFORM = 'MIRROR'
# PLATFORM = 'TEST'
PLATFORM = 'DEV'
# PLATFORM = 'MY'

if PLATFORM == 'PROD':
    appid = 'wxc141be76eec43a90'
    appsecret = '11c1d9b1638fa8655a4c2276ef71600b'
    base_url = 'http://isleep.16care.com'
elif PLATFORM == 'MIRROR':
    appid = 'wx724219604562346f'
    appsecret = '410dfdca7311781f51d079d89a875299'
    base_url = 'http://mirror.16care.com'
elif PLATFORM == 'TEST':
    appid = 'wx6826b4becf91a117'
    appsecret = '9f5f09c1d0720bb5b42db58016e3bb05'
    base_url = 'http://test.16care.com'
elif PLATFORM == 'DEV':
    appid = 'wx4901727b5f324009'
    appsecret = 'e698c8d6e2ac407679a13be213807663'
    base_url = 'http://dev.16care.com'
else:
    appid = 'wx03117df37c0ef955'
    appsecret = 'd4624c36b6795d1d99dcf0547af5443d'
    base_url = 'http://mazh.ersoft.cn'

STRUCT = {
    'appid': appid,
    'appsecret': appsecret,
    'base_url': urllib.quote_plus(base_url),
    'base_url_unquote': base_url
}

if __name__ == "__main__":
    wx = gzwechat_sdk.WeChatPublic(appid=STRUCT['appid'], appsecret=STRUCT['appsecret'])
    
    menu_dict = {
                    'button':[
                        # {
                            # 'name': '记录',
                            # 'sub_button': [
                        {
                            'type':'view',
                            'name':'享睡自评',
                            'url':STRUCT['base_url_unquote']+'/eroad_bracelet/sleep/record'
                            # 'url':'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+STRUCT['appid']+'&redirect_uri='+STRUCT['base_url']+'%2fgzwx%2findex%3fredirect%3d%2feroad_bracelet%2fsleep%2frecord&response_type=code&scope=snsapi_base&state=a#wechat_redirect'
                        },
                                # {
                                #     'type': 'view',
                                #     'name': '睡眠质量',
                                #     'url': 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+STRUCT['appid']+'&redirect_uri='+STRUCT['base_url']+'%2fgzwx%2findex%3fredirect%3d%2feroad_bracelet%2fsleep%2fanalysis&response_type=code&scope=snsapi_base&state=a#wechat_redirect'
                                # },
                                # {
                                #     'type': 'view',
                                #     'name': '就诊记录',
                                #     'url': 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+STRUCT['appid']+'&redirect_uri='+STRUCT['base_url']+'%2fgzwx%2findex%3fredirect%3d%2feroad_bracelet%2fpatient%2fmedical_record&response_type=code&scope=snsapi_base&state=a#wechat_redirect'
                                # },
                                # {
                                #     'type': 'view',
                                #     'name': '睡前日志',
                                #     'url': 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+STRUCT['appid']+'&redirect_uri='+STRUCT['base_url']+'%2fgzwx%2findex%3fredirect%3d%2feroad_bracelet%2fpatient%2frecord&response_type=code&scope=snsapi_base&state=a#wechat_redirect'
                                # },
                                # {
                                #     'type': 'view',
                                #     'name': '醒后自评',
                                #     'url': 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+STRUCT['appid']+'&redirect_uri='+STRUCT['base_url']+'%2fgzwx%2findex%3fredirect%3d%2feroad_bracelet%2fpsqi%2frecord&response_type=code&scope=snsapi_base&state=a#wechat_redirect'
                                # }
                            # ]
                        # },
                        # {
                        {
                            'type': 'view',
                            'name': '享睡养生',
                            'url':STRUCT['base_url_unquote']+'/eroad_bracelet/sleep/knowledge'
                            # 'url':'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+STRUCT['appid']+'&redirect_uri='+STRUCT['base_url']+'%2fgzwx%2findex%3fredirect%3d%2feroad_bracelet%2fsleep%2fknowledge&response_type=code&scope=snsapi_base&state=a#wechat_redirect'
                        },
                            # 'name': '易康养生',
                            # 'sub_button': [
                            #     {
                            #         'type': 'view',
                            #         'name': '睡眠疾病',
                            #         'url': STRUCT['base_url_unquote'] + '/eroad_bracelet/patient/sleep_disease'
                            #     },
                            #     {
                            #         'type': 'click',
                            #         'name': '睡眠知识',
                            #         'key': 'GOOD_HEALTH'
                            #     },
                            #     {
                            #         'type': 'view',
                            #         'name': '睡眠音乐',
                            #         'url': 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+STRUCT['appid']+'&redirect_uri='+STRUCT['base_url']+'%2fgzwx%2findex%3fredirect%3d%2fbracelet%2fdoctor%2fmusicindex&response_type=code&scope=snsapi_base&state=a#wechat_redirect'
                            #     },
                            #     {
                            #         'type': 'view',
                            #         'name': '周公解梦',
                            #         'url': 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+STRUCT['appid']+'&redirect_uri='+STRUCT['base_url'] + '%2fgzwx%2findex%3fredirect%3d%2feroad_bracelet_web_json%2fstatic%2fdream%2findex.html&response_type=code&scope=snsapi_base&state=a#wechat_redirect'
                            #     }
                            # ]
                        # },
                        {
                            'name': '我的',
                            'sub_button': [
                                # {
                                #     'type': 'view',
                                #     'name': '关注医生',
                                #     'url': 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+STRUCT['appid']+'&redirect_uri='+STRUCT['base_url']+'%2fgzwx%2findex%3fredirect%3d%2feroad_bracelet%2fpatient%2fdoctor_json_list&response_type=code&scope=snsapi_base&state=a#wechat_redirect'
                                # },
                                {
                                    'type': 'view',
                                    'name': '服药设置',
                                    'url': STRUCT['base_url_unquote']+'/eroad_bracelet/sleep/medicine_config'
                                    # 'url': 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+STRUCT['appid']+'&redirect_uri='+STRUCT['base_url']+'%2fgzwx%2findex%3fredirect%3d%2feroad_bracelet%2fsleep%2fmedicine_config&response_type=code&scope=snsapi_base&state=a#wechat_redirect'
                                },
                                {
                                    'type': 'view',
                                    'name': '个人详情',
                                    'url': STRUCT['base_url_unquote']+'/eroad_bracelet/patient/index'
                                    # 'url': 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+STRUCT['appid']+'&redirect_uri='+STRUCT['base_url']+'%2fgzwx%2findex%3fredirect%3d%2feroad_bracelet%2fpatient%2findex&response_type=code&scope=snsapi_base&state=bracelet#wechat_redirect'
                                },
                                # {
                                #     'type': 'view',
                                #     'name': '智能硬件',
                                #     'url': 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+STRUCT['appid']+'&redirect_uri='+STRUCT['base_url']+'%2fgzwx%2findex%3fredirect%3d%2feroad_bracelet%2foauth%2findex&response_type=code&scope=snsapi_base&state=bracelet#wechat_redirect'
                                # },
                                # {
                                #     'type': 'view',
                                #     'name': '已收红包',
                                #     'url': 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+STRUCT['appid']+'&redirect_uri='+STRUCT['base_url']+'%2fgzwx%2findex%3fredirect%3d%2feroad_bracelet%2fpatient%2fred_packet&response_type=code&scope=snsapi_base&state=rp#wechat_redirect'
                                # },
                                {
                                    'type': 'view',
                                    'name': '使用帮助',
                                    'url': STRUCT['base_url_unquote']+'/eroad_bracelet/patient/help'
                                    # 'url': 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+STRUCT['appid']+'&redirect_uri='+STRUCT['base_url']+'%2fgzwx%2findex%3fredirect%3d%2feroad_bracelet%2fpatient%2fhelp&response_type=code&scope=snsapi_base&state=help#wechat_redirect'
                                }
                            ]
                        }
                    ]}
    #print menu_dict
    res = wx.create_menu(menu_dict)
    print res
    
    print 'finished'
